home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Archives
/
ForCLI
/
whereis.lzh
/
date.c
next >
Wrap
C/C++ Source or Header
|
1991-02-16
|
838b
|
54 lines
#ifndef datetype
#include "date.h"
#endif
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif
ULONG leapyear (year)
ULONG year;
{
return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? 366L : 365L;
}
void date(datep, days)
struct date *datep;
register ULONG days;
{
register ULONG year=1978L, month=0L;
static ULONG DaysofMonth[]=
{ 31L, 28L, 31L, 30L,
31L, 30L, 31L, 31L,
30L, 31L, 30L, 31L };
year=1978L;
while (days >= 366L)
{
days-= leapyear(year);
year++;
}
if (days == 365L && leapyear(year)!= 366L)
{
days-=365L;
year++;
}
DaysofMonth[1]= leapyear(year)==366L? 29L : 28L;
while (days >= DaysofMonth[month])
{
days-=DaysofMonth[month];
month++;
}
days++;
month++;
datep->day= (short) days;
datep->month= (short) month;
datep->year= year;
}